package com.emcom.gotour.mvc.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.emcom.gotour.dao.TourSchedulerDao;
import com.emcom.gotour.mvc.model.TourContentModel;
import com.emcom.gotour.po.TourScheduler;
import com.emcom.gotour.service.TourCategoryService;
import com.emcom.gotour.service.TourContentService;
import com.emcom.gotour.vo.TourContentVO;

@Controller
public class DeleteSchedulerController {

	@Autowired
	private TourContentService tourContentService;

	@Autowired
	private TourCategoryService tourCategoryService;

	@Autowired
	private TourSchedulerDao tourSchedulerDao;

	@Autowired
	private MessageSource messageSource;

	@RequestMapping(value={"/admin/delete_scheduler_action.html"})
	public String deleteSchedulerAction(HttpServletRequest request) {
		TourScheduler tourScheduler = new TourScheduler();
		tourScheduler.setId(Long.valueOf(request.getParameter("id")));
		tourSchedulerDao.delete(tourScheduler);
		TourContentVO tourContentVO = tourContentService.queryContent(Long.valueOf(request.getParameter("tourId")));
		TourContentModel.getUpdateView(request, messageSource, tourCategoryService, tourContentVO);
		TourContentModel.setObject(request, tourContentVO);
		return "/admin/update_tour";
	}

}
